﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DotNetOpenAuth.OAuth;
using APITwitter.Handlers;

namespace APITwitter
{
    public partial class Callback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var accessTokenResponse = TwitterConsumer.Current.ProcessUserAuthorization();
                ltlScreenName.Text = accessTokenResponse.ExtraData["screen_name"];
                ViewState["AccessToken"] = accessTokenResponse.AccessToken;
                ViewState["ScreenName"] = accessTokenResponse.ExtraData["screen_name"];
            }

        }

        protected void btnSet_Click(object sender, EventArgs e)
        {
            SQLDBTokenManager.Current.UpdateAccessTokeScreenNameAndPassword(ViewState["AccessToken"].ToString(), ViewState["ScreenName"].ToString(), txtPassword.Text);
            lblOk.Text = "密码设置完毕";
        }
    }
}
